package cn.qyd.javastring;

import org.apache.commons.lang3.ArrayUtils;

import java.util.Arrays;
import java.util.regex.Pattern;
import java.util.stream.Stream;

/**
 * @author 邱运铎
 * @date 2024-03-11 18:27
 */
public class StringSplitAllMethodDemo {
    public static void main(String[] args) {
        String children = "邱运铎，一枚Java开发程序员";
        if (children.contains("，")) {
            String[] parts = children.split("，");
            System.out.println("第一部分： " + parts[0] + " 第二部分： " + parts[1]);
            System.out.println(Arrays.toString(parts));
        } else {
            throw new IllegalArgumentException("当前字符串没有包含逗号");
        }

        children = "邱运铎.一枚后端开发";
        if (children.contains(".")) {
            String[] parts = children.split("\\.");
            String[] parts1 = children.split("[.]]");
            String[] parts2 = children.split(Pattern.quote("."));
            Stream.of(parts).forEach(part -> System.out.print(part + "    "));
            System.out.println();
            Arrays.asList(parts1).forEach(part -> System.out.println("---" + part));
            System.out.println(Arrays.toString(parts1));
            System.out.println(Arrays.toString(parts2));
        }
    }
}
